from typing import Dict


class Code:
    OK: int = 0
    PARAM_ERROR: int = 10001
    NO_DATA: int = 10002
    MISS: int = 10404
    UNKNOWN: int = 19999
    SYSTEM_ERROR: int = 10888
    CONFIG_ERROR: int = 10866
    EXE_SHELL_ERROR: int = 10777
    REQUEST_ERROR: int = 11000
    JSON_PARSE_ERROR: int = 11001
    RUNTIME_ERROR: int = 11101
    JOB_NONE: int = 12101
    JOB_ALREADY_EXIST: int = 12101
    CLIENT_OFFLINE: int = 13101

    MESSAGES: Dict[int, str] = {
        OK: "操作成功",
        PARAM_ERROR: "参数错误",
        NO_DATA: "无数据",
        MISS: "接口不存在",
        UNKNOWN: "未知错误",
        SYSTEM_ERROR: "系统错误",
        CONFIG_ERROR: "配置错误",
        EXE_SHELL_ERROR: "shell 执行错误",
        REQUEST_ERROR: "网络请求错误",
        JSON_PARSE_ERROR: "JSON解析错误",
        RUNTIME_ERROR: "程序运行错误",
        JOB_NONE: "没有找到任务",
        JOB_ALREADY_EXIST: "任务已经存在",
        CLIENT_OFFLINE: "客户端掉线了",
    }

    @staticmethod
    def message(code: int = 0) -> str:
        """
        获取提示信息
        """
        message = Code.MESSAGES.get(code)
        if message is None:
            return "未知错误"
        else:
            return message
